
int slot_event = 0;

#define SLOT_PIN_INIT 2
#define SLOT_PIN_HIGH 1
#define SLOT_PIN_LOW 0

int slot_init(standby_t *standby_prarm)
{
    pthread_pool_work_add(t_pool, slot_read_pin_loop, &gstandby_prarm);
}

static void *slot_read_pin_loop(void *arg)
{
	fd_set rd;
	struct timeval tv;
	int err;

	int cur_other_slot = SLOT_PIN_INIT, pre_other_slot = SLOT_PIN_INIT;

    while(1)
    {
		FD_ZERO(&rd);
		FD_SET(0,&rd);

		tv.tv_sec = 5;
		tv.tv_usec = 0;
		err = select(1,&rd,NULL,NULL,&tv);  //监听对端卡槽的在位管脚
        if(err < 0)
        {

		}
        int cur_other_slot = hardware_get_cardslot();//read_slot_pin();
		
        if(cur_other_slot == SLOT_PIN_HIGH )
        {
             if(pre_other_slot == SLOT_PIN_INIT)//对方不在，第一次启动，单卡
             {
                 slot_event = SLOT_NULL_EVENT;
			 }
             else if(pre_other_slot == SLOT_PIN_LOW)//对方前一次在位，拔卡
             {
                slot_event = SLOT_OUT_EVENT;
			 }
			 else //对方不在
			 {
                 slot_event = SLOT_NULL_EVENT;
			 }
		}
		else//对方在位，双卡
		{
		    if(gstandby_prarm->role == UNKNOWN)//(pre_other_slot == SLOT_ONLINE_PIN_HIGH)
		    {

			}
			else
			{   

		    }

		}
        pre_other_slot = cur_other_slot;

    }

}


